package fxmedia;

// Import Java JDK Classes
import java.io.File;
import java.net.URI;

// Import JID3 Classes
import org.blinkenlights.jid3.MP3File;

// Import Apache Commons I/O Classes
import org.apache.commons.io.FilenameUtils;

/**
* @author dca
*/
public class MediaFile extends File {
	/** Unique ID for serialization.<br/> */
	private static final long serialVersionUID = 9088245852490257240L;

	/** The ID3 information object.<br/> */
	private MP3File id3Info;

	/**
	 * Creates a new media file from the specified file object.<br/>
	 * @param file The mp3 file.<br/>
	 */
	public MediaFile(File file) {
		super(file.getAbsolutePath());
		id3Info = new MP3File(file);
	} // END constructor

	/**
	 * Creates a new media file from the specified file path.<br/>
	 * @param pathname The path to the mp3 file.<br/>
	 */
	public MediaFile(String pathname) {
		super(pathname);
		id3Info = new MP3File(new File(pathname));
	} // END constructor

	/**
	 * Creates a new media file from the specified URI.<br/>
	 * @param uri The resource indicator for the mp3 file.<br/>
	 */
	public MediaFile(URI uri) {
		super(uri);
		id3Info = new MP3File(new File(uri));
	} // END constructor

	/**
	 * Returns the file name, without the extension.<br/>
	 */
	@Override
	public String toString() {
		return FilenameUtils.removeExtension(this.getName());
	} // END toString

	/**
	 * Returns the ID3 information object.<br/>
	 * @return id3Info The ID3 information object.<br/>
	 */
	public MP3File getId3Info() {
		return id3Info;
	} // END getId3Info
} // END class MediaFile
